package com.hurl.stock.util;

import java.io.IOException;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

import com.hurl.stock.base.StockServerCfg;

public class HttpUtils {
	
	public static String executeGetMethod(String url) throws ClientProtocolException, IOException{
		HttpClient client = new DefaultHttpClient();
		client.getParams().setIntParameter("http.connection.timeout",StockServerCfg.getHttpClientTimeOut());
		HttpGet getMethod = new HttpGet(url);
		HttpResponse response = client.execute(getMethod);
		HttpEntity entity = response.getEntity();
		String responseContent = EntityUtils.toString(entity);
		EntityUtils.consume(entity);
		return responseContent;
	}
}
